home *** CD-ROM | disk | FTP | other *** search
/ Utilities Professional 1-1500 / Utilities Professional 1-1500 (1994)(WPD)[!].iso / 12511500 / var1463.dms / var1463.adf / BBBBS72.lha / rexxDoors / Time.rexx < prev   
OS/2 REXX Batch file  |  1994-01-28  |  3KB  |  130 lines

  1. /* Time.rexx         by Greg Cunningham 1990    stolen from Unix TODAY.C */
  2.  
  3. CR='0D'x
  4. temp=date(o)
  5. parse var temp year'/'mon'/'day .
  6. say 'Today is' date(w)', the' nbrtxt(day%1,1)' day of' date(m)',' nbrtxt(19,0) nbrtxt(year,0)'.'CR
  7.  
  8. ctime=time()
  9. parse var ctime hour':'min':'sec
  10. hr=hour//12
  11. if(hr=0) then hr=12
  12. str='The big hand is on the' nbrtxt((((min+2+sec%30)%5+11)//12)+1,0)
  13. say str 'and the little hand is on the' nbrtxt(hr,0)'.'CR
  14.  
  15. exit
  16.  
  17.  
  18. /*
  19.  * Integer to Readable ASCII Conversion Routine.
  20.  *
  21.  * Synopsis:
  22.  *
  23.  * string=nbrtxt(value,ordinal)
  24.  *    value    -- The number to output
  25.  *    ordinal -- Non-zero for ordinal number
  26.  *
  27.  *
  28.  *     say nbrtxt(0,0) ==> "zero"
  29.  *     say nbrtxt(0,1) ==> "zeroth"
  30.  *
  31.  * Largest number:
  32.  *    nine hundred ninety-nine thousand, nine hundred ninety-nine
  33.  *
  34.  */
  35.  
  36. nbrtxt: procedure
  37.  
  38.     arg val,ordflag
  39.  
  40.     cardinal.0='zero'
  41.     cardinal.1='one'
  42.     cardinal.2='two'
  43.     cardinal.3='three'
  44.     cardinal.4='four'
  45.     cardinal.5='five'
  46.     cardinal.6='six'
  47.     cardinal.7='seven'
  48.     cardinal.8='eight'
  49.     cardinal.9='nine'
  50.     cardinal.10='ten'
  51.     cardinal.11='eleven'
  52.     cardinal.12='twelve'
  53.     cardinal.13='thirteen'
  54.     cardinal.14='fourteen'
  55.     cardinal.15='fifteen'
  56.     cardinal.16='sixteen'
  57.     cardinal.17='seventeen'
  58.     cardinal.18='eighteen'
  59.     cardinal.19='nineteen'
  60.  
  61.     ordinal.0='zeroth'
  62.     ordinal.1='first'
  63.     ordinal.2='second'
  64.     ordinal.3='third'
  65.     ordinal.4='fourth'
  66.     ordinal.5='fifth'
  67.     ordinal.6='sixth'
  68.     ordinal.7='seventh'
  69.     ordinal.8='eighth'
  70.     ordinal.9='ninth'
  71.     ordinal.10='tenth'
  72.     ordinal.11='eleventh'
  73.     ordinal.12='twelfth'
  74.  
  75.     twenties.2='twen'
  76.     twenties.3='thir'
  77.     twenties.4='for'
  78.     twenties.5='fif'
  79.     twenties.6='six'
  80.     twenties.7='seven'
  81.     twenties.8='eigh'
  82.     twenties.9='nine'
  83.  
  84.     op=''
  85.     if(val<0) then do
  86.         op = 'minus '
  87.         val=(-val);
  88.     end
  89.     if(val>=1000) then do
  90.         op=op||nbrtxt(val%1000,0);
  91.         op=op 'thousand'
  92.         val=val//1000
  93.         if(val=0) then do
  94.             if(ordflag=1) then op=op'th'
  95.             return op
  96.         end
  97.         if(val>=100) then op=op', '
  98.         else op=op 'and '
  99.     end
  100.     if(val>=100) then do
  101.         num=val%100
  102.         op=op||cardinal.num 'hundred'
  103.         val=val//100
  104.         if(val=0) then do
  105.             if(ordflag=1) then op=op'th'
  106.             return op
  107.         end
  108.         op=op' '
  109.     end
  110.     if(val>=20) then do
  111.         if(val=90 & ordflag=1) then return op'nintieth' /* ninetieth? */
  112.         num=val%10
  113.         op=op||twenties.num
  114.         val=val//10
  115.         if(val=0) then do
  116.             if(ordflag=1) then op=op'tieth'
  117.             else op=op'ty'
  118.             return op
  119.         end
  120.         op=op'ty-'
  121.     end
  122.     if(val<=12) then do
  123.         if(ordflag=1) then op=op||ordinal.val
  124.         else op=op||cardinal.val
  125.         return op
  126.     end
  127.     op=op||cardinal.val
  128.     if(ordflag=1) then op=op'th'
  129.     return op
  130.